package com.whp.openapi.web.controller;

import com.whp.openapi.common.ResponseResult;
import com.whp.openapi.common.ResultTable;
import com.whp.openapi.entity.UserToken;
import com.whp.openapi.service.UserTokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author whp
 * @date 2021/11/27
 */
@RestController
@RequestMapping("/token")
public class UserTokenController {

    @Autowired
    private UserTokenService userTokenService;

    /**
     * token管理：搜索、分页
     * @param page
     * @param limit
     * @param accessToken
     * @return
     */
    @RequestMapping("/table")
    public ResultTable table(@RequestParam(defaultValue = "1") Integer page, 
                             @RequestParam(defaultValue = "10") Integer limit,
                             String accessToken) {
        return userTokenService.table(page, limit, accessToken);
    }

    /**
     * 删除
     * @param ids
     * @return
     */
    @RequestMapping("/del")
    public ResponseResult delUserToken(Integer[] ids) {
        return userTokenService.delUserToken(ids);
    }

    /**
     * 添加
     * @param userToken
     * @return
     */
    @RequestMapping("/add")
    public ResponseResult addUserToken(UserToken userToken) {
        return userTokenService.addUserToken(userToken);
    }

    /**
     * 编辑
     * @param userToken
     * @return
     */
    @RequestMapping("/update")
    public ResponseResult updateUserToken(UserToken userToken) {
        return userTokenService.updateUserToken(userToken);
    }
}
